<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:g="http://giava.by/common/base"
	template="/WEB-INF/layout/t.xhtml">

	<ui:define name="title">
		<h:outputText
			value="Gestione Immagine per Categorie Prodotti e Sinistri" />
	</ui:define>
	<ui:define name="roles">
		<f:attribute name="roles" value="insurance-claim" />
	</ui:define>

	<ui:define name="content">
		<center>
			<h:form enctype="multipart/form-data">
				<p:panel header="Gestione Categoria - Immagine">
					<h:panelGrid columns="2" style="width: 95%">
						<h:outputLabel for="name" value="Nome (*):" style="width: 100%;" />
						<h:outputText id="name"
							value="#{insuranceClaimCategoryController.element.name}"
							style="width: 100%;" />

						<h:outputLabel for="description" value="Descrizione:"
							style="width: 100%;" />
						<h:outputText id="description"
							value="#{insuranceClaimCategoryController.element.description}"
							style="width: 100%;" escape="false" />

						<h:outputLabel value="Immagine:" for="image"
							rendered="#{not empty insuranceClaimCategoryController.element.image}" />
						<h:graphicImage id="image"
							value="/img/#{insuranceClaimCategoryController.element.image.filename}"
							alt="#{insuranceClaimCategoryController.element.image.filename}"
							title="#{insuranceClaimCategoryController.element.image.filename}"
							style="padding: 5px;"
							rendered="#{not empty insuranceClaimCategoryController.element.image}" />
						<h:outputLabel value="Carica il nuovo file:" for="fileUpload" />
						<p:fileUpload mode="simple" id="fileUpload"
							value="#{insuranceClaimCategoryController.element.newImage.uploadedData}" />
					</h:panelGrid>
					<br />
				</p:panel>

				<h:panelGrid columns="4">

					<h:commandButton action="#{insuranceClaimCategoryController.save}"
						value="Salva" immediate="false"
						rendered="#{not insuranceClaimCategoryController.editMode}" />

					<h:commandButton
						action="#{insuranceClaimCategoryController.update}"
						value="Salva le modifiche" immediate="false"
						rendered="#{insuranceClaimCategoryController.editMode}" />

					<h:commandButton
						action="#{insuranceClaimCategoryController.deleteImg}"
						value="Elimina immagine"
						rendered="#{insuranceClaimCategoryController.editMode}"
						immediate="true"
						onclick="if (!confirm('Vuoi davvero eliminare l\' immagine ?')) return false" />
				</h:panelGrid>
			</h:form>
		</center>


	</ui:define>
</ui:composition>